package com.kikyou.api;


import com.kikyou.pojo.*;

import com.kikyou.service.ICategoryService;
import com.kikyou.service.IOplogService;
import com.kikyou.service.IPositionLevelService;
import com.kikyou.service.IPositionService;
import com.kikyou.utils.AdminUtils;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @program: kikyouback
 * @author: 李玉龙
 * @create: 2022-03-08 10:53
 **/
@RestController
@RequestMapping("/organization/sequence")
public class PositionController {
    @Autowired
    IPositionService iPositionService;
    @Autowired
    IPositionLevelService iPositionLevelService;
    @Autowired
    ICategoryService iCategoryService;
    @Autowired
    IOplogService oplogServiceImpl;
    @ApiOperation(value = "获取职位序列")
    @GetMapping("/{currentPage}/{pageSize}")
    public RespBean getiPosition(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
     return iPositionService.getiPosition(currentPage,pageSize);
    }

    @ApiOperation(value = "创建职位序列")
    @PostMapping("/")
    public RespBean PostiPosition(@RequestBody Position position) {
       return iPositionService.PostiPosition(position);
    }

    @ApiOperation(value = "编辑职位序列")
    @PutMapping("/")
    public RespBean PutPosition(@RequestBody Position position){
     return iPositionService.PutPosition(position);
    }

    @ApiOperation(value = "删除职位序列")
    @DeleteMapping("/{id}")
    public RespBean DelPosition(@PathVariable("id") int id){
        boolean b = iPositionService.removeById(id);
        if (b) {
            oplogServiceImpl.insertMessage("删除职位序列成功");
            return RespBean.success("删除职位序列成功");
        }
        return RespBean.error("删除职位序列失败");
    }
}